home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / ANTENNA / YAGIU112 / README < prev    next >
Encoding:
Text File  |  1995-08-07  |  17.4 KB  |  357 lines

  1. TITLE:  YagiUda-1.09.tar.Z and yagiu109.zip
  2.  
  3. PURPOSE: To analyse performance of Yagi-Uda antennas. You
  4. give the dimensions and positions of each element, and the
  5. program calculates gain, input impedance, front-to back ratio,
  6. beam-patterns etc. An optimisation program 'optimise' tries to
  7. optimise a design. The optimiser can also tell you the sensitivity
  8. of a good design, to small mechanical errors.
  9.  
  10. AUTHOR: David Kirkby BSc. MSc.  G8WRB.
  11. email:davek@medphys.ucl.ac.uk
  12.              Department of Medical Physics,
  13.              University College London,
  14.              11-20 Capper St,
  15.              London WC1E 6JA.
  16.              Telephone: 071-380-9700
  17.              Fax: 071-380-9577. 
  18.  
  19. The *latest* version will be found on the anonymous ftp site medphys.ucl.ac.uk
  20. While other ftp sites are keeping the program (eg ftp.funet.fi), I'm always
  21. goind to put the latest version on my machine at work first. 
  22.  
  23. INTRODUCTION.
  24. Four binary programs, INPUT, YAGI, OUTPUT, OPTIMISE and FIRST
  25. are used for the analysis and optimisation:
  26.  
  27. INPUT asks for data about a Yagi and writes it to a disk file, in
  28. a standard ASCII format. The file name the data is written to is
  29. specified by the user, in response to the program.
  30.  
  31. FIRST puts data about a very rough Yagi into a file. It is used for getting
  32. dimensions of Yagis of arbitrary number of elements quickly. It will *not*
  33. give a good design, but can be used as a starting point for further 
  34. optimisation.
  35.  
  36. YAGI computes yagi performance, using as input the file created
  37. by INPUT or FIRST. It writes data to a file with a '.out' suffix. The '.out'
  38. file is a binary file containing (amongst other things) the element
  39. currents. On a PC, running unix, fitted with 16Mb of RAM, a 400
  40. element Yagi has been analysed! As far as I'm aware, the size of
  41. antenna that can be analysed is not limited in any way by 
  42. the program - only your memory available.
  43.  
  44. OUTPUT reads the element currents from the '.out' file and
  45. computes forwardgain, input impedance, front to back ratio etc
  46. and puts these in a file with a '.dat' suffix. The gain in both
  47. the E and H planes is put into a file with a '.gai' prefix. Both
  48. the '.dat' and '.gai' files are ASCII and their format is easy to
  49. understand by inspection.
  50.  
  51. OPTIMISE takes a design you have, then tries to randomly
  52. change element lengths and positions, so that the antenna works
  53. better. If it's better, it keeps the new design, if not its scraped.
  54. What is 'better' is defined by the user. For example is an
  55. antenna that has higher gain, but also higher VSWR better or 
  56. worst? You choose what you want to optimise. Optimising just
  57. gain usually results in an antenna with an impractically low input
  58. impedance.
  59. If, for example, the user runs INPUT, and enters '4ele' as the
  60. filename, then INPUT creates a file called '4ele'. After typing
  61. 'yagi 4ele', we will have a file '4ele.out', containing the element
  62. currents. We then type 'output 4ele' where we will get the
  63. following files: '4ele.dat' and '4ele.gai'. If we then type
  64. 'optimise 4ele 123' this will take the design for the 4
  65. element yagi, try to change lengths or positions upto 0.1%,
  66. using juest parasitic elements, optimising for gain,
  67. F/B ratio and vswr. It will try this 123 times. Run
  68. 'optimise' with no arguments to get a list of the required parameters.
  69. Optimise gives you a running commentry of its current best performance
  70. on the screen (stdout) and in a file '4ele.up'. The best design (ie
  71. positions of elements etc) is in a file '4ele.bes'.
  72.  
  73. If you create a file called 'stop' in the directory in which optimise 
  74. is running, optimise will stop after a few seconds. This allows one to
  75. set it running for a long time, but pause it if needed. Simply killing
  76. the process will of cource stop it, but it may leave you with no results,
  77. as the results files are continuously being deleted! If you ask 'optimise'
  78. to run for say 123 iterations (as in the example above), but it stops after 
  79. just 100, its probably becuse you have a file called 'stop' in existance. Use
  80. 'touch stop' to create 'stop' and 'rm stop' to remove it.
  81.  
  82.  
  83.  
  84. IMPORTANT
  85.  
  86. To achieve high accuracy, accurate analytical equations are used
  87. in the program. These equations need evaluation of the sine
  88. integral and cosine integral. Some copy-righted software is used
  89. in evaluating these functions. Also, copy-righted software is
  90. used in matrix computations and complex number calculations.
  91. Hence the full source code is *not* given. However, the
  92. copy-righted routines can *very* cheaply be purchased. They are
  93. printed in the book 'Numerical Recipes in C', 2nd edition, by Press
  94. et al, Cambridge University Press (1992). Many scientific academic 
  95. departments (physics, maths, engineering etc etc) will have
  96. a copy of the book, but it can be purchased easily by anyone. A
  97. disk with the routines on can also be purchased. Unfortunately,
  98. the  1st edition of the book will not do, as one of the routines
  99. used 'cisc()' for sine and cosine integral evaluation, was not
  100. printed in the 1st edition.
  101.  
  102. FILES:
  103.  
  104. better.c                   Determines if a design is better or not.
  105. cis_hack.c                 Calculation of sine and cosine integrals.
  106. com_hack.c                 Complex number routines.
  107. copym.c                    Copy matrix a to matrix b.
  108. gain.c                     Gain of an antenna
  109. ga_lib.c                   Genetic algorithm library routines.
  110. getfiles.c                 Checks arguments, then opens files.
  111. header.c                   Writes header to disk file.
  112. input.c                    Program requests data, then writes to ASCII file.
  113. lub_hack.c                 Back substitution (matrix algebra).
  114. lud_hack.c                 LU decomposition (matrix algebra)
  115. mpr_hack.c                 Iterative improvment of simultaneous equ's
  116. mutual.c                   Calculates mutual impedance between elements.
  117. nrutil.c                   PD Numerical routines (utilite routines).
  118. num_ele.c                  Returns number of elements from data file.
  119. optimise.c                 Program to optimise a Yagi-Uda antenna design.
  120. output.c                   Program to put Yagi performance into ASCII file.
  121. pin.c                      Calculates power input to antenna (in Watts).
  122. print_z.c                  Prints the impedance matrix; for debugging.
  123. randomis.c                 Randomises element positions/lengths.
  124. read_data.c                Reads a yagi description into memory.
  125. read_header.c              Reads a header created by 'yagi'.
  126. read_perf.c                Reads perpormance of yagi (gain. F/B etc)
  127. refco.c                    Calculates the reflection coefficent.
  128. self.c                     Calculates self impedance of an element.
  129. string.c                   Allocates and frees memory for strings.
  130. v.c                        Fills voltage vector (V).
  131. vswr.c                     Calculates the VSWR of antenna.
  132. write_cords.c              Writes coordinates of elements to disk.
  133. write_gain.c               Writes gain in E and H plane.  
  134. write_ip_dat.c             Used by 'input'. Writes yagi to disk.
  135. yagi.c                     Main program for calculation of element currents.
  136. z.c                        Fills impedance (Z) matrix.
  137. zbr_hack.c                 Hacked version of zbrent.c in NR book.
  138. z_input.c                  Computes input impedance of yagi.
  139. CHANGES                    List of changes made.
  140. dosmake                    DOS Makefile
  141. makefile                   Unix makefile.
  142. optimise.1                 Unix man page for optimise.
  143. optimise.doc               ASCII version of above.
  144. optimise.cat               Catable man page (does not require nroff).
  145.  
  146. There are also some example files (see below), plus a few others (shell scrips
  147. etc) that I used. These are of no use, but I dont always remeber to remove them.
  148.  
  149. PLATFORMS TESTED ON.
  150.  
  151. This set of program have been test on these systems:
  152. 1) A i486 PC with 16Mb of RAM running Interactive Systems Unix, System V, 
  153. version 3.2, release 2.0.2. Compiled with g++.
  154. 2) A  Sun Classic running SunOs 4.1.3_U1. Compiled with acc.
  155. 3) A 90MHz Pentium PC running DOS. Compiled with gcc. 
  156.  
  157. There are few if any system specific calls or anything that I think
  158. will cause problems if converted to other systems. Memory requiremnts are 
  159. modest by todays standards. The memory necessary depends on the size of the
  160. antenna, as bigger arrays are necessary to hold more element data for large
  161. Yagis. A minimum of 2Mb will probably be necessary, but I can't say
  162. for sure.
  163.  
  164.  
  165. BUILDING THE EXECUTABLES
  166.  
  167. Since some routines are missing, its important to follow these
  168. instructions carefully.
  169.  
  170. 1) Get hold of the following files from the 2nd edition of the
  171. Numerical Recipes book. Please dont ask me for them.
  172.  
  173. cisi.c                   Sine and cosine integral evaluation.
  174. complex.c                General complex maths.
  175. lubksb.c                 Back substitution of a real matrix.
  176. ludcmp.c                 LU decomposition of a real matrix.
  177. mprove.c                 Iterative improvement of simulateous equ's.
  178. zbrent.c                 Brent's algoritm for root searching.
  179.  
  180. 2) Change *all* references in these 4 files from  float to double.
  181. Any references to routines 'vector' should be changed to 'dvector'
  182. , references to 'matrix' should be changed to 'dmatrix',
  183. references to 'free_vector' to 'free_dvector' etc.
  184. The routines 'vector', 'matrix' are numerical recipe routines
  185. for allocating memory for single precision vectors or matrices.
  186. The 'dvector' etc is for double precision.
  187.  
  188. Rename all files with ie. cisi.c to cis_hack.c, complex.c to 
  189. com_hack.c ludcmp.c lud_hack.c and lubksb.c to lub_hack.c and mprove.c to
  190. mpr_hack.c, zbrent.c zbr_hack.c. This will avoid confusion later if you happen to use the recipes in another application. 
  191.  
  192. 3) Remove any references to "nr.h", "nrutil.h" in these 5 files.
  193.  
  194. 4) Add a line:
  195. #include "yagi.h" to each of the five files. "yagi.h" includes
  196. hacked versions of the original numerical recipe header files.
  197.  
  198. 5) In the file complex_hack.c, delete the line (line 5) that says:
  199.  
  200. typedef struct FCOMPLEX ...
  201.  
  202. 5) Type 'make'. You should get five executables, 'input', 'yagi', 
  203. 'output', 'optimise' ,'first' and 'rantest'. Its assumed that your compiler 
  204. defines 'i386' on a unix PC, 'sun' on a Sun and DOS on a DOS PC. There are a 
  205. few '#ifdef sun' statements in a few of the C files. On other systems you might
  206. try defining one or the other of these using (usually) the -D
  207. option on your compiler. Try defining 'sun' or 'i386' in the makefile,
  208. on the CFLAGS in the makefile where 'ANSI' has been defined. 
  209.  
  210. 6) Run the program 'rantest' and check the output is as its says it
  211. should be. If not, there are problems with the random number generators,
  212. which are used extensivly in the 'optimise' program, but not in any of the
  213. others.
  214.  
  215. EXAMPLES 
  216.  
  217. There are a number of example files. I've included the '.dat' and '.gain' 
  218. files from 'output'. These might be of use when testing your programs.
  219.  
  220. 1ele        This is a single element, exactly 1.0m long. It is obviously
  221.             a half-wave at exactly 150MHz. Note that it resonates not at
  222.             150MHz, but at approximately 145MHz, where its gain is 2.11dBi.
  223.             At 150MHz its gain is the well known 2.15dBi (2.15dBi=0dB 
  224.             referenced to a dipole), but its not resonate. 
  225.  
  226. 70cm33      A 33 ele yagi for 70cm amateur band.
  227.  
  228. 200         This is just a test design. It has 200 elements! Its not
  229.              any good at all as an antenna, but is included to test
  230.             the programs for a large design. The program 'optimise' is
  231.             most likely to limit you for large antennas. The matrices
  232.             used in 'optimise' are much bigger than in 'output'. 'yagi'
  233.                 also needs large matirces.
  234. 2m6         2m, 6element yagi.
  235.  
  236. SCRIPT FILE
  237.  
  238. A file called 'TYPESCRIPT' should be included with the distribution you 
  239. received. This is a complete session of using the programs to analyse
  240. and optimise a yagi. This was produced using the program 'script' on the
  241. Sun computer. It should help you see exactly how to use the programs.
  242.  
  243. FILE FORMATS:
  244.  
  245. The files created by 'input' and 'output' are ASCII and their
  246. format should be easy to see by inspection. Lines beginning with
  247. a hash (#) are comments. The .out file, as created by yagi is a
  248. binary file and its format is described below. There is a 100 byte
  249. header, consisting of:
  250.  
  251. offset(bytes)              info                 data-type
  252.  
  253. 0                          elements             int
  254. 4                          driven               int
  255. 8                          parasitic            int
  256. 12                         min_frequency        double
  257. 20                         max_frequency        double
  258. 28                         design frequency     double
  259. 36                         step_frequency       double
  260. 44                         angular_step         double
  261. 52                         0                    double
  262. .                          .                      .
  263. .                          .                      .
  264. .                          .                      .
  265. 92                         0                    double
  266.  
  267. Following the header, there starts the coordinates(x,y,l) of each
  268. element and the voltage applied to each element. Then we write
  269. the element currents one after the other, at each frequency.
  270. Hence the element currents will be written 12,000 times with a
  271. 3 element yagi analysed at 4,000 different frequencies.
  272. 100                        x1                   double /* coordinates */
  273. 108                        y1                   double
  274. 116                        l1                   double
  275. 100+(n-1)*24               x_n                  double
  276. 100+(n-1)*24+8             y_n                  double
  277. 100+(n-1)*24+16            l_n                  double
  278. .............. Repeated for each element.
  279. 100+24*elements            Voltage1             fcomplex 
  280. 100+24*elements+(n-1)*16   Voltage_n            fcomplex
  281. .............. Repeated for each element n at each frequency step f.
  282. 100+40*elements         Current1@f1             fcomplex
  283. 100+40*elements+(n-1)*16 Current_n@f1           fcomplex
  284.  
  285. 100+56*elements         Current@f2              fcomplex
  286. 100+40*elements+(n-1)*16 Current_n@f2           fcomplex
  287.  
  288. The file with the extension '.gai' gives the gain at every frequency
  289. in both the H(xy) and E(xz) planes. It is difficult to make the coordinate
  290. system clear without a diagram. See Lawsons book, as I've used exactly the
  291. same system as him.
  292.  
  293. The antenna sits in the horizontal (xz) plane. The forward direction of
  294. gain is towards the +x direction. Phi, the elevation angle varies from
  295. 0 degrees along the x axis, through 90 degrees along the y axis, to 180
  296. degrees along the -x axis. The gain on the H plane is given in both units
  297. relative to an isotropic radiator (dBi) in the ( gain-H(dBi) column ) and
  298. dB relative to the peak (in the gain(H)-peak column). Phi is listed 
  299. from 0 to 180 degrees.
  300.  
  301. The gain in the E (xz) plane is also given in two columns, one in dBi,  
  302. the other refered to the peak. Theta (the azimuthal angle) goes from
  303. 90 along the x axis, 180 degrees along the z axis to 270 degrees along
  304. the -x axis.
  305.  
  306. Hence the direction of peak forward gain is theta=90, the backward
  307. direction is theta=270. At theta is 180 degrees (off the side of the
  308. beam), the radiation is theoretically zero. The '.gain' file lists
  309. it at -999.0000 dBi. The  front to back ratio, which is listed in the
  310. '.dat' file, is simply G(theta=90)/G(theta=270).
  311.  
  312. The '.gai' file has 7 columns. The first one (frequency) is common
  313. to the other 6. However, the 2nd (theta) is only concerned with the 
  314. 3rd and 4th. It has nothing watsoever to do with the last 3. 
  315. Similarily, the 5th column (phi) is only concerned with the 6th and 7th
  316. coulmns. 
  317.  
  318. PUBLICATION
  319.  
  320. I've submitted the theory (not source code) of how this program works to 
  321. RadCom, the publication of the Radio Society of Great Britain. Keep a look out 
  322. in RadCom, since it may be published.  This was refused once, but will be
  323. re-submited.
  324.  
  325.  
  326. KNOWN PROBLEMS:
  327.   
  328. In a typical Yagi, the element lengths are approximately
  329. half-wave. If a Yagi is analysed well away from the usual
  330. frequency (3x, where elements are approximaely 1.5 wavelengths
  331. long) then the self impedance formulae will be inaccurate, as it
  332. assumes a sinusoidal current distribution, high in the middle,
  333. zero at ends. This makes the input impedance of the antenna
  334. have a negative real part. This implies a negative power absorbed
  335. by the antenna, (ie antenna supplies power). Hence the gain
  336. becomes negative. Taking the log (to get dB) of a negative gain
  337. gives numerical errors. 
  338.  
  339. WARNING
  340.  
  341. Using software random number generators can be a problem. Many of the 
  342. random number generators on computer systems are rather poor, having a
  343. short repeat period, or subsequent numbers being correlated in some way.
  344. Better (but slower) random number gererators are available - see for
  345. example 'ran0()', 'ran1()' etc in the Numerical Recipes book. A system
  346. random number generator (drand48()) has been used here, with no attempt
  347. made to correct any defficiencies. I dont *think* its properties are critical
  348. in this application, hence I just used the fast(ish) system supplied routine,
  349. but warn you that it is not necessarily good. The random number generator is
  350. only used in the optimise program. It properties will not affect the accuracy
  351. of any results, but it may change the speed with which you get a better design.
  352.  
  353. KEEP IN TOUCH
  354.  
  355. If you find this program interesting/useful, mail me and I'll let you know of
  356. updates etc. email:davek@medphys.ucl.ac.uk
  357.